<?php echo $javascript->link('jquery.min.js', false); ?>
<?php echo $javascript->link('jquery.pager.js', false); ?>
<?php echo $javascript->link('jquery-ui-1.7.2.custom.min.js', false); ?>
<?php echo $javascript->link('button', false); ?>

<?php
// 隐藏和显示提示信息
echo $javascript->codeBlock('
    function hide_flash_message() {
        $("#flashMessage").slideUp();
        $(".nav-updir").after("<a id=\'showFlashMessage\' href=\'#\'>显示讯息</a>");
        $("#showFlashMessage").click(function() {
            $("#flashMessage").slideDown();
            $(this).remove();
        });
    }
    $(document).ready(function() {
			$(".user-action .ui-icon-plusthick").click(function() {
				$(this).toggleClass("ui-icon-minusthick");
				$(this).parents(".filebox:first").find(".description").toggle("fast");
			});
        $("#flashMessage").append("<a id=\'hideFlashMessage\' href=\'#\'>隐藏讯息</a>");
        $("#hideFlashMessage").click(hide_flash_message);
    });
    
', array('inline' => false));
?>

<?php
// 用来动态处理文件删除，感觉不是很好，故暂不使用
/* echo $javascript->codeBlock('
    $(document).ready(function() {
        $(".admin-action .delete").click(function(event) {
            var filebox = $(this).parents(".filebox");
            event.preventDefault();
            $.getJSON($(this).attr("href") + "/true", function(data) {
                $("#flashMessageWrapper").empty();
                $("#flashMessageWrapper").html("<div id=\'flashMessage\'>" + data.message + "</div>");
                if (data.failure) $("#flashMessage").addClass("failure");
                if (data.success) {
                    $("#flashMessage").addClass("success");
                    filebox.remove();
                }
            });
        });
    });
', array('inline' => false)); */
?>

<div class="nav">
    <span class="nav-updir">
        <?php 
                // if($showEntry) 
                    // echo $html->link(__('管理入口', true), $html->url('/admin/users/viewUsers', true)); 
        ?>
    </span>
    <?php if($currentEntry->filename != '') { ?>
        <span class="nav-currentpath">当前目录 <?php echo $currentEntry->filename; ?></span>
    <?php } ?>
</div>

<?php echo $this->element('sidepain'); ?>

<div class="maincontent filelist">
    <div id="flashMessageWrapper"><?php $session->flash(); ?></div>

    <?php if (!empty($childEntries)) {
        $i = 0; foreach ($childEntries as $name => $entry) { ?>
    <div class="filebox ui-widget ui-widget-content ui-corner-all">
    	<div class="file-header ui-widget-header">
            <div style="float: left">
            <?php echo ++$i; ?>
            <?php echo $html->link($entry->Name, "/ftpfiles/detail/{$entry->b64filename}"); ?>
            </div>
            <div class="action user-action">
                <?php if ($entry->is_dir()): ?>
                    <a href="<?php echo $html->url('/ftpfiles/download_from_ftp/'.$entry->b64filename);?>" class="fg-button ui-state-default" title="<?php __('FTP Browse'); ?>"><span class="ui-icon ui-icon-folder-open"></span></a>
                    <a href="<?php echo $html->url('/ftpfiles/download_as_zip/'.$entry->b64filename);?>" class="fg-button ui-state-default" title="<?php __('Download as ZIP'); ?>"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span></a>
                <?php else: ?>
                    <a href="<?php echo $html->url('/ftpfiles/download_from_ftp/'.$entry->b64filename);?>" class="fg-button ui-state-default" title="<?php __('Download from FTP'); ?>"><span class="ui-icon ui-icon-disk"></span></a>
                <?php endif; ?>
                <a href="<?php echo $html->url('/collections/add_collect/'.$entry->b64filename);?>" class="fg-button ui-state-default" title="<?php __('Add to my collection'); ?>"><span class="ui-icon ui-icon-bookmark"></span></a>
				<a class="fg-button ui-state-default" title="<?php __('show all the information'); ?>"><span class="ui-icon ui-icon-plusthick"></span></a>
            </div>
            <?php
                if($session->read('Auth.User.username') == 'admin') {
               ?>
            <span class="action admin-action">
                <a class="fg-button ui-state-default ui-corner-all"
                   href='<?php echo $html->url("/ftpfiles/unlink/{$entry->b64filename}"); ?>'
                   title="<?php __('Delete'); ?>">
                    <span class="ui-icon ui-icon-trash"></span>
                </a>
            </span>
            <?php } ?>
            
            </div>
        <span class="file-type"><label>类型:</label> <?php echo $entry->is_dir() ? '文件夹' : '文件'; ?></span>
        
        <span class="file-size"><label>大小:</label> <?php echo $ftpman->smart_size($entry->Size);?></span>
        <span class="file-count"><label>下载次数:</label> <?php echo $entry->DownloadCount;?></span>
        <div class="description"><?php echo $entry->Description; ?></div>
    </div>
    <?php }} ?>
</div>
